//
//  FZ_CreatView.m
//  ProjectOfBStage
//
//  Created by dllo on 15/11/17.
//  Copyright © 2015年 cuixin. All rights reserved.
//

#import "FZ_RightCreatViewDongH.h"
#import "BaseHeader.h"

@interface FZ_RightCreatViewDongH ()
@property (nonatomic , retain) UIView *viewTouXiang;
@property (nonatomic , retain) UIImageView *imageViewTouXiang;
@end

@implementation FZ_RightCreatViewDongH

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.viewTouXiang = [[UIView alloc] initWithFrame:frame];
        self.viewTouXiang.backgroundColor = [UIColor clearColor];
        [_viewTouXiang release];
        self.viewTouXiang.userInteractionEnabled = YES;
//            self.viewTouXiang.layer.shadowOpacity = 1;
        //    self.viewTouXiang.layer.shadowColor = [UIColor yellowColor].CGColor;
//        self.viewTouXiang.layer.shadowRadius = 10;
        self.viewTouXiang.layer.cornerRadius = 18;
        self.viewTouXiang.layer.borderColor = [UIColor clearColor].CGColor;
        //    self.viewTouXiang.layer.borderWidth = 2;
        UIImage *imageRight = RIGHT_ITEM_BAR;
        imageRight = [imageRight imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        [self.imageViewTouXiang removeFromSuperview];
        self.imageViewTouXiang = [[UIImageView alloc] initWithFrame:self.viewTouXiang.frame];
        self.imageViewTouXiang.image = imageRight;
        self.imageViewTouXiang.layer.cornerRadius = 18;
        self.imageViewTouXiang.clipsToBounds = YES;
        self.imageViewTouXiang.layer.masksToBounds = YES;
        self.imageViewTouXiang.layer.backgroundColor = [UIColor blackColor].CGColor;
        //    self.imageViewTouXiang.layer.borderWidth = 2;
        self.imageViewTouXiang.layer.borderColor = [UIColor whiteColor].CGColor;
        self.imageViewTouXiang.userInteractionEnabled = YES;
        [self.viewTouXiang addSubview:self.imageViewTouXiang];
        [_imageViewTouXiang release];
        
        CABasicAnimation *basicanimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
        [basicanimation setDuration:3];
        [basicanimation setFromValue:[NSNumber numberWithInt:0]];
        [basicanimation setToValue:[NSNumber numberWithFloat:M_PI * 2]];
        [basicanimation setAutoreverses:NO];
        [basicanimation setRepeatCount:FLT_MAX];
        [self.imageViewTouXiang.layer addAnimation:basicanimation forKey:@"transform"];
        basicanimation.autoreverses = YES;
        [self addSubview:self.viewTouXiang];
    }
    return self;
}

- (void)removeAnimat{
    [self.imageViewTouXiang.layer removeAllAnimations];
}

@end
